@scrider/formatter 1.3.6 → 1.3.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -2612,7 +2612,11 @@ function resolveDocumentPresentation(presentation) {
2612
2612
  return { lineSpacing, textIndentCm };
2613
2613
  }
2614
2614
  var LINE_HEIGHT_TAGS = /* @__PURE__ */ new Set(["p", "li", "blockquote"]);
2615
- var TEXT_INDENT_TAGS = /* @__PURE__ */ new Set(["p", "li"]);
2615
+ var TEXT_INDENT_TAGS = /* @__PURE__ */ new Set(["p"]);
2616
+ function documentPresentationListWrapperStyleParts(resolved) {
2617
+ if (!resolved?.textIndentCm) return [];
2618
+ return [`padding-left:calc(1.5em + ${resolved.textIndentCm}cm)`];
2619
+ }
2616
2620
  function documentPresentationStyleParts(tag, resolved) {
2617
2621
  if (!resolved) return [];
2618
2622
  const parts = [];
@@ -2737,7 +2741,13 @@ function deltaToHtml(delta, options = {}) {
2737
2741
  continue;
2738
2742
  }
2739
2743
  if (isList) {
2740
- html += handleListOpen(listStack, listType, indent, pretty);
2744
+ html += handleListOpen(
2745
+ listStack,
2746
+ listType,
2747
+ indent,
2748
+ pretty,
2749
+ resolvedDocumentPresentation
2750
+ );
2741
2751
  if (hierarchicalNumbers && listType === "ordered") {
2742
2752
  if (counters.length > indent + 1) {
2743
2753
  counters = counters.slice(0, indent + 1);
@@ -3016,9 +3026,13 @@ function renderCodeBlock(codeLines, language, embedRenderers, pretty, blockHandl
3016
3026
  </code></pre>`;
3017
3027
  return pretty ? html + "\n" : html;
3018
3028
  }
3019
- function handleListOpen(stack, listType, indent, pretty) {
3029
+ function handleListOpen(stack, listType, indent, pretty, resolvedDocumentPresentation) {
3020
3030
  let html = "";
3021
3031
  const wrapperTag = LIST_WRAPPER_TAGS[listType] || "ul";
3032
+ const openWrapperTag = () => {
3033
+ const styleAttr = stack.length === 0 ? joinStyleParts(documentPresentationListWrapperStyleParts(resolvedDocumentPresentation)) : "";
3034
+ return `<${wrapperTag}${styleAttr}>`;
3035
+ };
3022
3036
  while (stack.length > 0) {
3023
3037
  const last = stack[stack.length - 1];
3024
3038
  if (!last || last.indent <= indent) break;
@@ -3045,7 +3059,7 @@ function handleListOpen(stack, listType, indent, pretty) {
3045
3059
  const currentIndent = last ? last.indent + 1 : 0;
3046
3060
  if (currentIndent > indent) break;
3047
3061
  if (pretty) html += getIndent(stack.length);
3048
- html += `<${wrapperTag}>`;
3062
+ html += openWrapperTag();
3049
3063
  if (pretty) html += "\n";
3050
3064
  stack.push({ type: listType, indent: currentIndent });
3051
3065
  if (currentIndent >= indent) break;
@@ -3053,7 +3067,7 @@ function handleListOpen(stack, listType, indent, pretty) {
3053
3067
  const current = stack[stack.length - 1];
3054
3068
  if (!current || current.indent < indent) {
3055
3069
  if (pretty) html += getIndent(stack.length);
3056
- html += `<${wrapperTag}>`;
3070
+ html += openWrapperTag();
3057
3071
  if (pretty) html += "\n";
3058
3072
  stack.push({ type: listType, indent });
3059
3073
  }